﻿namespace WMS6.Services
{
    using System;
    using System.Collections.Generic;
    using System.Data;
    using System.ServiceModel;
    using System.ServiceModel.Activation;
    using WMS6.BLL;
    using WMS6.Common;
    using WMS6.DataEntity;
    using WMS6.QueryEntity;

    [AspNetCompatibilityRequirements(RequirementsMode=AspNetCompatibilityRequirementsMode.Allowed), ServiceBehavior(InstanceContextMode=InstanceContextMode.PerCall)]
    public class CustomsService : ICustomsService
    {
        public string DeleteDeclarationsInfo(List<string> DeclarationsID, PubParasInfo pubParasInfo)
        {
            string temp = string.Empty;
            try
            {
                temp = new ImportDeclarationsBLL(pubParasInfo).DeleteDeclarationsInfo(DeclarationsID);
                new OperationLogBLL().Insert("CustomsService_Delete_IMPORT_DECLARATIONS", DeclarationsID, pubParasInfo);
                return temp;
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "ICustomsService异常");
            }
            return temp;
        }

        public string DeleteEXDeclarationsInfo(List<string> DeclarationsID, PubParasInfo pubParasInfo)
        {
            string temp = string.Empty;
            try
            {
                temp = new ExportDeclarationsBLL(pubParasInfo).DeleteDeclarationsInfo(DeclarationsID);
                new OperationLogBLL().Insert("CustomsService_Delete_EXPORT_DECLARATIONS", DeclarationsID, pubParasInfo);
                return temp;
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "ICustomsService异常");
            }
            return temp;
        }

        public DataSet GetDeclarationsBlanaceRptDataSet(DeclarationsBlanaceRptQueryEntity declarationsBlanaceRptQueryEntity, PubParasInfo pubParasInfo)
        {
            try
            {
                AnalyticsReportBLL analyticsReoprtBll = new AnalyticsReportBLL(pubParasInfo);
                return analyticsReoprtBll.GetDeclarationsBlanaceRptDataSet(declarationsBlanaceRptQueryEntity);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "AnalyticsReportServices异常");
            }
            return null;
        }

        public ImportDeclarationsInfo GetDeclarationsInfoByID(string DeclarationsID, PubParasInfo pubParasInfo)
        {
            try
            {
                ImportDeclarationsBLL importDeclarationsBLL = new ImportDeclarationsBLL(pubParasInfo);
                return importDeclarationsBLL.GetDeclarationsInfoByID(DeclarationsID);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "ICustomsService异常");
            }
            return null;
        }

        public DataSet GetDeclarationsInfoByQueryEntity(ImportDeclarationsQueryEntity importDeclarationsQueryEntity, PubParasInfo pubParasInfo)
        {
            try
            {
                ImportDeclarationsBLL importDeclarationsBLL = new ImportDeclarationsBLL(pubParasInfo);
                return importDeclarationsBLL.GetDeclarationsInfoByQueryEntity(importDeclarationsQueryEntity);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "ICustomsService异常");
            }
            return null;
        }

        public DataSet GetDeclarationsInOutDetailRptDataSet(DeclarationsInOutDetailRptQueryEntity declarationsInOutDetailRptQueryEntity, PubParasInfo pubParasInfo)
        {
            try
            {
                AnalyticsReportBLL analyticsReoprtBll = new AnalyticsReportBLL(pubParasInfo);
                return analyticsReoprtBll.GetDeclarationsInOutDetailRptDataSet(declarationsInOutDetailRptQueryEntity);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "AnalyticsReportServices异常");
            }
            return null;
        }

        public DataSet GetDeclarationsItemNoBlanaceRptDataSet(DeclarationsItemNoBlanaceRptQueryEntity declarationsItemNoBlanaceRptQueryEntity, PubParasInfo pubParasInfo)
        {
            try
            {
                AnalyticsReportBLL analyticsReoprtBll = new AnalyticsReportBLL(pubParasInfo);
                return analyticsReoprtBll.GetDeclarationsItemNoBlanaceRptDataSet(declarationsItemNoBlanaceRptQueryEntity);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "AnalyticsReportServices异常");
            }
            return null;
        }

        public ExportDeclarationsInfo GetEXDeclarationsInfoByID(string DeclarationsID, PubParasInfo pubParasInfo)
        {
            try
            {
                ExportDeclarationsBLL exportDeclarationsBLL = new ExportDeclarationsBLL(pubParasInfo);
                return exportDeclarationsBLL.GetDeclarationsInfoByID(DeclarationsID);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "ICustomsService异常");
            }
            return null;
        }

        public DataSet GetEXDeclarationsInfoByQueryEntity(ExportDeclarationsQueryEntity exportDeclarationsQueryEntity, PubParasInfo pubParasInfo)
        {
            try
            {
                ExportDeclarationsBLL exportDeclarationsBLL = new ExportDeclarationsBLL(pubParasInfo);
                return exportDeclarationsBLL.GetDeclarationsInfoByQueryEntity(exportDeclarationsQueryEntity);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "ICustomsService异常");
            }
            return null;
        }

        public DataSet GetExportDeclarationsRptDateSet(ExportDeclarationsRptQueryEntity exportDeclarationsRptQueryEntity, PubParasInfo pubParasInfo)
        {
            try
            {
                AnalyticsReportBLL analyticsReoprtBll = new AnalyticsReportBLL(pubParasInfo);
                return analyticsReoprtBll.GetExportDeclarationsRptDateSet(exportDeclarationsRptQueryEntity);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "AnalyticsReportServices异常");
            }
            return null;
        }

        public DataSet GetImportDeclarationsRptDateSet(ImportDeclarationsRptQueryEntity importDeclarationsRptQueryEntity, PubParasInfo pubParasInfo)
        {
            try
            {
                AnalyticsReportBLL analyticsReoprtBll = new AnalyticsReportBLL(pubParasInfo);
                return analyticsReoprtBll.GetImportDeclarationsRptDateSet(importDeclarationsRptQueryEntity);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "AnalyticsReportServices异常");
            }
            return null;
        }

        public string InsertDeclarationsInfo(ImportDeclarationsInfo importDeclarationsInfo, PubParasInfo pubParasInfo)
        {
            string temp = string.Empty;
            try
            {
                temp = new ImportDeclarationsBLL(pubParasInfo).InsertDeclarationsInfo(importDeclarationsInfo);
                new OperationLogBLL().Insert("CustomsService_Insert_IMPORT_DECLARATIONS", importDeclarationsInfo, pubParasInfo);
                return temp;
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "ICustomsService异常");
            }
            return temp;
        }

        public string InsertEXDeclarationsInfo(ExportDeclarationsInfo exportDeclarationsInfo, PubParasInfo pubParasInfo)
        {
            string temp = string.Empty;
            try
            {
                temp = new ExportDeclarationsBLL(pubParasInfo).InsertDeclarationsInfo(exportDeclarationsInfo);
                new OperationLogBLL().Insert("CustomsService_Insert_EXPORT_DECLARATIONS", exportDeclarationsInfo, pubParasInfo);
                return temp;
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "ICustomsService异常");
            }
            return temp;
        }

        public ExportDeclarationsInfo OrderIDChanged(string orderID, string type, string ownerID, PubParasInfo pubParasInfo)
        {
            try
            {
                ExportDeclarationsBLL exportDeclarationsBLL = new ExportDeclarationsBLL(pubParasInfo);
                return exportDeclarationsBLL.OrderIDChanged(orderID, type, ownerID, pubParasInfo);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "ICustomsService异常");
            }
            return null;
        }

        public ImportDeclarationsInfo ReceiptIDChanged(string recepitID, string type, string ownerID, PubParasInfo pubParasInfo)
        {
            try
            {
                ImportDeclarationsBLL importDeclarationsBLL = new ImportDeclarationsBLL(pubParasInfo);
                return importDeclarationsBLL.ReceiptIDChanged(recepitID, type, ownerID, pubParasInfo);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "ICustomsService异常");
            }
            return null;
        }

        public string UpdateDeclarationsInfo(ImportDeclarationsInfo importDeclarationsInfo, PubParasInfo pubParasInfo)
        {
            string temp = string.Empty;
            try
            {
                temp = new ImportDeclarationsBLL(pubParasInfo).UpdateDeclarationsInfo(importDeclarationsInfo);
                new OperationLogBLL().Insert("CustomsService_Update_IMPORT_DECLARATIONS", importDeclarationsInfo, pubParasInfo);
                return temp;
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "ICustomsService异常");
            }
            return temp;
        }

        public string UpdateDeclarationsInfoData(ImportDeclarationsInfo importDeclarationsInfo, PubParasInfo pubParasInfo)
        {
            string temp = string.Empty;
            try
            {
                temp = new ImportDeclarationsBLL(pubParasInfo).UpdateDeclarationsInfoData(importDeclarationsInfo, pubParasInfo);
                new OperationLogBLL().Insert("CustomsService_Update_IMPORT_DECLARATIONS", importDeclarationsInfo, pubParasInfo);
                return temp;
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "ICustomsService异常");
            }
            return temp;
        }

        public string UpdateDeclarationsStatus(string declarationsID, string status, string verificationFormID, PubParasInfo pubParasInfo)
        {
            string temp = string.Empty;
            try
            {
                ImportDeclarationsBLL importDeclarationsBLL;
                string str = "";
                string CS40001 = status;
                if (CS40001 != null)
                {
                    if (!(CS40001 == "Audited"))
                    {
                        if (CS40001 == "New")
                        {
                            goto Label_0057;
                        }
                        if (CS40001 == "WrittenOff")
                        {
                            goto Label_005F;
                        }
                        if (CS40001 == "Auditeds")
                        {
                            goto Label_0067;
                        }
                    }
                    else
                    {
                        str = "Audit";
                    }
                }
                goto Label_0076;
            Label_0057:
                str = "RevertAudit";
                goto Label_0076;
            Label_005F:
                str = "WrittenOff";
                goto Label_0076;
            Label_0067:
                str = "RevertWrittenOff";
                status = "Audited";
            Label_0076:
                importDeclarationsBLL = new ImportDeclarationsBLL(pubParasInfo);
                temp = importDeclarationsBLL.UpdateDeclarationsStatus(declarationsID, status, verificationFormID, pubParasInfo);
                ImportDeclarationsInfo importDeclarationsInfo = new ImportDeclarationsInfo();
                importDeclarationsInfo.DeclarationsID = declarationsID;
                new OperationLogBLL().Insert("CustomsService_" + str + "_IMPORT_DECLARATIONS", importDeclarationsInfo, pubParasInfo);
                return temp;
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "ICustomsService异常");
            }
            return temp;
        }

        public string UpdateEXDeclarationsInfo(ExportDeclarationsInfo exportDeclarationsInfo, PubParasInfo pubParasInfo)
        {
            string temp = string.Empty;
            try
            {
                temp = new ExportDeclarationsBLL(pubParasInfo).UpdateDeclarationsInfo(exportDeclarationsInfo);
                new OperationLogBLL().Insert("CustomsService_Update_EXPORT_DECLARATIONS", exportDeclarationsInfo, pubParasInfo);
                return temp;
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "ICustomsService异常");
            }
            return temp;
        }

        public string UpdateEXDeclarationsInfoData(ExportDeclarationsInfo exportDeclarationsInfo, PubParasInfo pubParasInfo)
        {
            string temp = string.Empty;
            try
            {
                temp = new ExportDeclarationsBLL(pubParasInfo).UpdateDeclarationsInfoData(exportDeclarationsInfo, pubParasInfo);
                new OperationLogBLL().Insert("CustomsService_Update_EXPORT_DECLARATIONS", exportDeclarationsInfo, pubParasInfo);
                return temp;
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "ICustomsService异常");
            }
            return temp;
        }

        public string UpdateEXDeclarationsStatus(string declarationsID, string status, string verificationFormID, PubParasInfo pubParasInfo)
        {
            string temp = string.Empty;
            try
            {
                ExportDeclarationsBLL exportDeclarationsBLL;
                string str = "";
                string CS40001 = status;
                if (CS40001 != null)
                {
                    if (!(CS40001 == "Audited"))
                    {
                        if (CS40001 == "New")
                        {
                            goto Label_0057;
                        }
                        if (CS40001 == "WrittenOff")
                        {
                            goto Label_005F;
                        }
                        if (CS40001 == "Auditeds")
                        {
                            goto Label_0067;
                        }
                    }
                    else
                    {
                        str = "Audit";
                    }
                }
                goto Label_0076;
            Label_0057:
                str = "RevertAudit";
                goto Label_0076;
            Label_005F:
                str = "WrittenOff";
                goto Label_0076;
            Label_0067:
                str = "RevertWrittenOff";
                status = "Audited";
            Label_0076:
                exportDeclarationsBLL = new ExportDeclarationsBLL(pubParasInfo);
                temp = exportDeclarationsBLL.UpdateDeclarationsStatus(declarationsID, status, verificationFormID, pubParasInfo);
                ExportDeclarationsInfo exportDeclarationsInfo = new ExportDeclarationsInfo();
                exportDeclarationsInfo.DeclarationsID = declarationsID;
                new OperationLogBLL().Insert("CustomsService_" + str + "_EXPORT_DECLARATIONS", exportDeclarationsInfo, pubParasInfo);
                return temp;
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "ICustomsService异常");
            }
            return temp;
        }
    }
}

